export default {
  install(Vue) {
    // 防止重复点击
    Vue.directive('throttle', {
      inserted(el, binding) {
        console.log("binding-7", binding)
        el.addEventListener('click', () => {
          if (!el.disabled) {
            el.disabled = true
            setTimeout(() => {
              el.disabled = false
            }, binding.value || 1000)
          }
        })
      }
    })
    Vue.directive('copy', {
      bind: function (el, binding) {
        console.log("copy=======", el, binding)
        console.log("copy=======", binding.value, binding.arg)
        setTimeout(() => {
          var clipboard = new Clipboard(el, {
            text: function () {
              return "123123";
            },
            action: function () {
              return "copy"
            },
            container: document.body
          });
          clipboard.on('success', function (e) {
            console.log('Copy succeeded: ' + e.text);
          });
          clipboard.on('error', function (e) {
            console.log('Copy failed: ' + e.text);
          });
        }, 1000)
      }
    });
  }
}
